//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.ruoyi.system.feign.service.impl;

import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.domain.SysDictData;
import com.ruoyi.system.feign.service.IRemoteDictService;
import com.ruoyi.system.service.ISysDictTypeService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;

@Service
public class RemoteDictServiceImpl implements IRemoteDictService {
    @Autowired
    private ISysDictTypeService sysDictTypeService;

    public RemoteDictServiceImpl() {
    }

    public String getDictLabel(String dictType, String dictValue, String separator) {
        System.out.println("调用成功");
        StringBuilder propertyString = new StringBuilder();
        List<SysDictData> datas = this.sysDictTypeService.selectDictDataByType(dictType);
        Iterator var6;
        SysDictData dict;
        if (StringUtils.containsAny(dictValue, separator) && CollectionUtils.isNotEmpty(datas)) {
            var6 = datas.iterator();

            while(true) {
                while(var6.hasNext()) {
                    dict = (SysDictData)var6.next();
                    String[] var8 = dictValue.split(separator);
                    int var9 = var8.length;

                    for(int var10 = 0; var10 < var9; ++var10) {
                        String value = var8[var10];
                        if (value.equals(dict.getDictValue())) {
                            propertyString.append(dict.getDictLabel() + separator);
                            break;
                        }
                    }
                }

                return StringUtils.stripEnd(propertyString.toString(), separator);
            }
        } else {
            var6 = datas.iterator();

            while(var6.hasNext()) {
                dict = (SysDictData)var6.next();
                if (dictValue.equals(dict.getDictValue())) {
                    return dict.getDictLabel();
                }
            }

            return StringUtils.stripEnd(propertyString.toString(), separator);
        }
    }

    public String getDictValue(String dictType, String dictLabel, String separator) {
        System.out.println("调用成功");
        StringBuilder propertyString = new StringBuilder();
        List<SysDictData> datas = this.sysDictTypeService.selectDictDataByType(dictType);
        Iterator var6;
        SysDictData dict;
        if (StringUtils.containsAny(dictLabel, separator) && CollectionUtils.isNotEmpty(datas)) {
            var6 = datas.iterator();

            while(true) {
                while(var6.hasNext()) {
                    dict = (SysDictData)var6.next();
                    String[] var8 = dictLabel.split(separator);
                    int var9 = var8.length;

                    for(int var10 = 0; var10 < var9; ++var10) {
                        String label = var8[var10];
                        if (label.equals(dict.getDictLabel())) {
                            propertyString.append(dict.getDictValue() + separator);
                            break;
                        }
                    }
                }

                return StringUtils.stripEnd(propertyString.toString(), separator);
            }
        } else {
            var6 = datas.iterator();

            while(var6.hasNext()) {
                dict = (SysDictData)var6.next();
                if (dictLabel.equals(dict.getDictLabel())) {
                    return dict.getDictValue();
                }
            }

            return StringUtils.stripEnd(propertyString.toString(), separator);
        }
    }
}
